<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%	

'	Authorization level 3 needed for this function
	If Session("userLevel") < 4 Then 
		response.redirect("menu.aspx?msgtype=E&msgno=" & MSGNO_AUTHORIZATION_FAILED)
	End if

	Dim i
			
'   	if cancel go back to main menu
	if request.form("cancel") <> "" then
		response.redirect("default.asp")
	End If 

	call MakeConn(objConn, DATABASE)	
	Call MakeRs_add(objRs,objConn,"SELECT * FROM Options")			
		
	If objRS.EOF = true then
		response.redirect("menu.aspx?msgtype=E&msgno=" & MSGNO_OPTION_NOT_FOUND)
	End if		
	objRS.movefirst

'	Page called by itself, update first (et only) record
	if request.form("update") <> ""  then		
		objRS("cutoffPeriod") = request("cutoffPeriod")
		objRS("cutoffMonth") = request("cutoffMonth")
		objRS("cutoffYear") = request("cutoffYear")
		
		objRS.update
		
		session("CutOffDate") = CutoffDate(  request("cutoffPeriod"), request("cutoffMonth"), request("cutoffYear"), "end" )
		
		destroy(objRS)
		destroy(objConn)
		
		response.redirect("menu.aspx?msgtype=I&msgno=" & MSGNO_UPDATE_DONE)
	
	End If
%>
		
<html><!-- InstanceBegin template="/Templates/common.dwt" codeOutsideHTMLIsLocked="false" -->
<!--#include virtual="/timereport/include/auth.asp" -->
<!--#include virtual="/timereport/include/common.asp" -->

<head>
<!-- InstanceBeginEditable name="doctitle" -->
<title>Gestione cutoff</title>
<!-- InstanceEndEditable --> 
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<!-- InstanceBeginEditable name="head" -->
<link href="include/commoncss.asp" rel="stylesheet" type="text/css">
<!-- InstanceEndEditable -->
</head>

<SCRIPT language=JavaScript src= "/timereport/include/menu/menu_array.js" type=text/javascript></SCRIPT>
<SCRIPT language=JavaScript src= "/timereport/include/menu/mmenu.js" type=text/javascript></SCRIPT>

<body>
<table width="760" border="0" align="left" cellpadding="0" cellspacing="0">
  <tr> 
    <td height="30" class="BarraTop"><div align="right">Utente: <%= session("UserName") %> 
      </div></td>
  </tr>
  <tr>
    <td height="30">&nbsp;</td>
  </tr>
  <tr> <!-- InstanceBeginEditable name="principale" --> 
    <td >
	<form name="form1" method="post" action="cutoff.asp">
        <table width="60%" border="0" align="center" cellpadding="0" cellspacing="0" class="TabellaBianca">
          <tr>
            <td>Inserire la quindicina da cui bloccare l'input</td>
          </tr>
        </table>
        <br>
        <table width="60%" border="0" align="center" cellpadding="0" cellspacing="1" class="TabellaForm">
          <tr> 
            <th width="20%" nowrap>Quindicina</th>
            <td> <select name="cutoffPeriod" class="FormInput">
                <%	
	For i = 1 to 2
%>
                <option value="<%=i%>" <% if objRS("cutoffPeriod")=i Then response.write("selected") End If%>><%=i%></option>
                <%	
	Next 
%>
              </select> </td>
          </tr>
          <tr> 
            <th nowrap>Mese</th>
            <td> <select name="cutoffMonth" class="FormInput">
                <%	For i = 1 to 12%>
                <option value="<%=i%>" <% if objRS("cutoffMonth")=i Then response.write("selected") End If%>><%=i%></option>
                <%	Next %>
              </select> </td>
          </tr>
          <tr> 
            <th nowrap>Anno</th>
            <td> <select name="cutoffYear" class="FormInput">
                <%	For i = FIRST_YEAR to LAST_YEAR %>
                <option value="<%=i%>" <% if objRS("cutoffYear")=i Then response.write("selected") End If%>><%=i%></option>
                <%	Next %>
              </select> </td>
          </tr>
        </table>
	    <br>
        <table width="60%" border="0" align="center" cellpadding="0" cellspacing="0">
          <tr> 
            <td> 
              <input type="submit" name="update" value="aggiorna" class="FormButtont">
              <input type="submit" name="cancel" value=" annulla " class="FormButtont"> 
            </td>
          </tr>
        </table>
      </form>
	  </td>
<%
	destroy(objRS)
	destroy(objConn)
%>	  	  
    <!-- InstanceEndEditable --></tr>
</table>
</body>
<!-- InstanceEnd --></html>
